﻿using Furion.DatabaseAccessor;
using Furion.DependencyInjection;
using Htx.Fur.Core.ContextLocators;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Htx.Fur.Core.Entities
{
    [SuppressSniffer]
    public class DataDic: Entity<int, SqliteDbContextLocator>, IEntitySeedData<DataDic>, IEntityTypeConfiguration<DataDic>
    {
        [Comment("显示名称")]
        public string Name { get; set; }

        public string Value { get; set; }

        public string Group { get; set; }

        /// <summary>
        /// 数据库实体配置
        /// </summary>
        /// <param name="builder"></param>
        public void Configure(EntityTypeBuilder<DataDic> builder)
        {
            builder.HasComment("数据字典表");
            builder.HasIndex(a => a.Group);
        }

        /// <summary>
        /// 种子数据
        /// </summary>
        /// <param name="dbContext"></param>
        /// <param name="dbContextLocator"></param>
        /// <returns></returns>
        public IEnumerable<DataDic> HasData(DbContext dbContext, Type dbContextLocator)
        {
            return new List<DataDic> 
            { 
                new DataDic{ Id = 1, Name = "已下单", Value = "Ordered", Group = "OrderStatus" },
                new DataDic{ Id = 2, Name = "已接单", Value = "Receviced", Group = "OrderStatus" }
            };
        }
    }
}
